<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div {
            width: 400px;
            height: 400px;
            /*垂直对齐方式：把行高值设置成高度即可*/
            line-height: 400px;
            background-color: pink;
            text-align: center;
        }
    </style>
</head>
<body>
<div>文字</div>
</body>
</html>